﻿using MediatR;
using Production_Get.API.Application.Commands.OrderShow;
using Production_Get.API.Infrastructures.Interfaces;
using Return.Enum;
using THE_WIND_RISES.Common.Dtos;

namespace Production_Get.API.Application.Commands.Warehousingtes
{
    public class OrderTineSrcetenHandler : IRequestHandler<OrderTineSrcetenCommend, Result>
    {
        private readonly IBaseRepositoryGet<OrderTineDto> OrderTineDto;

        public OrderTineSrcetenHandler(IBaseRepositoryGet<OrderTineDto> OrderTineDto)
        {
            this.OrderTineDto = OrderTineDto;
        }

        public async Task<Result> Handle(OrderTineSrcetenCommend request, CancellationToken cancellationToken)
        {
            var result = new Result() { Code = (int)CommonErrorCodes.Search };

            string sql = "SELECT * FROM OrderTine a INNER JOIN ItemInfo b on a.InventoryInfoId=b.InventoryInfoId where a.IsDelete=0 AND a.StorageId=" + request.StorageId;

            var list = OrderTineDto.GetAll(sql, default).ToList();
            if (list != null)
            {
                result.Code = (int)CommonErrorCodes.Success;
                result.Data = list;
                result.Msg = "显示成功";
            }

            return result;
        }
    }
}
